package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    //菜品分页查询
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    //菜品起售、停售
    @Update("update dish set status=#{status},update_time=now() where id=#{id}")
    void updateStatus(Integer status, String id);

    //根据分类id查询菜品
    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> selectByCategoryId(Integer categoryId);

    //新增菜品
    void addDish(Dish dish);

    //根据id查询菜品
    @Select("select * from dish where id=#{id}")
    DishVO selectById(Long id);

    //批量查询status
    List<Long> getStatusesByIds(List<Long> ids);

    //修改菜品
    void updateDish(Dish dish);

    //批量删除菜品
    void deleteByIds(List<Long> ids);

    //查询启售中菜品
    @Select("select * from dish where category_id=#{categoryId} and status=#{status}")
    List<Dish> list(Dish dish);

    //根据条件统计菜品数量
    Integer countByMap(Map map);
}
